<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<c:url value="/resources/css/view.css"/>" >
</head>

<h1>Cart</h1>

<form:form modelAttribute="order" method="POST" action="">
<table class="search">
<tr>
 <td><form:errors path="orderedItems" cssClass="error"/></td>
</tr>
<c:forEach var="orderedItem" items="${order.orderedItems}" varStatus="status">
	<form:hidden path="orderedItems[${status.index}].product.productId" />
<%-- 	<form:hidden path="orderedItems[${status.index}].order" /> --%>
<%-- 	<form:hidden path="orderedItems[${status.index}].productQuantity" /> --%>
   <tr>
   <td><c:out value="${orderedItem.product.name}" /></td>
   
  <td><form:input path= "orderedItems[${status.index}].productQuantity"/></td> 
   <td><c:out value="${orderedItem.productPrice}" /></td>
	<c:url var="removeUrl" value="/order/cart/remove" >
 		<c:param name="id" value="${orderedItem.product.productId}" />
    </c:url>
	<td>
        <a href='<c:out value="${removeUrl}"/>'>remove</a>
    </td>
    </tr>
</c:forEach>
</table>
<c:if test="${!notEmpty}">
	<p>Your cart is empty! </p>
</c:if>
<input type="submit" name="action" value="ok" />
<c:if test="${loggedIn}">
	<c:if test="${notEmpty}">
		<input type="submit" name="action" value="order" />
	</c:if>
</c:if>
<td><a href="<c:url value="/home"/>">home</a></td>
</form:form>
</html>
            